﻿@model indicadores.Models.Indicador
@{
    ViewBag.Title = "Indicadores";
    Layout = "~/Views/Shared/Layout.cshtml";
}
@section Head{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/Cadastro.css")" rel="stylesheet" type="text/css" />
    @*<script src="../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>
    *@<style>
          a:hover
          {
              padding: 0;
          }
          #mais, #menos
          {
              width: 15px;
              height: 15px;
              cursor:pointer;
          }
          #mais
          {
              margin-left:10px;
              margin-right:5px;
          }
          #menos
          {
              margin-right:10px;
          }
      </style>
    <script type="text/javascript">
        $(document).ready(function () {
            var i = 0;
            $("#mais").click(function () {
                i = i + 1;
                $(".subcadastro").append("<div id='" + i + "'><p class='separador'></p><div class='editor-label'><label for='v.nome'>Nome:</label></div><div class='editor-field'><input type='text' name='v[" + i + "].Nome' /></div><div class='editor-label'><label for='v.unidade'>Unidade:</label></div><div class='editor-field'><input type='text' name='v[" + i + "].Unidade' /></div></div>");
                $("#" + i).hide();
                $("#" + i).slideDown();
            });
            $("#menos").click(function () {
                if (i > 0) {
                    $("#" + i).slideUp(function () {
                        $(this).remove();
                    });
                    i = i - 1;
                }
            });
        });
    </script>
}
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>
            <h2>
                Adicionar Indicador</h2>
        </legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Nome)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Nome)
            @Html.ValidationMessageFor(model => model.Nome)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Atualizacao)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Atualizacao)
            @Html.ValidationMessageFor(model => model.Atualizacao)
        </div>
        <br />
        <fieldset class="subcadastro">
            <legend>
                <h3>
                    Variaveis<img id="mais" alt="adicionar variavel" src="../../Content/imagens/mais.gif" />
                    <img id="menos" src="../../Content/imagens/menos.gif" alt="retirar variavel" /></h3>
            </legend>
            <div id="0">
                <div class="editor-label">
                    <label for="v.nome">
                        Nome:</label></div>
                <div class="editor-field">
                    <input type="text" name="v[0].Nome" id="n"/>
                </div>
                <div class="editor-label">
                    <label for="v.unidade">
                        Unidade:</label></div>
                <div class="editor-field">
                    <input type="text" name="v[0].Unidade" id="u" />
                </div>
            </div>
        </fieldset>
        <p>
            <input type="submit" value="Adicionar" />
        </p>
    </fieldset>
}
@Html.ActionLink("Voltar", "Detalhes", new { id = Convert.ToInt32(Request.RawUrl.Split('/')[3]) })
